Minimum Spanning Tree Python Code